Skip to content

Conversation

tzolov
Copy link
Contributor

@tzolov tzolov commented Jan 28, 2024

  • Add OpenAiChatOptions

    • Add OpenAiChatOptions that implements ChatOptions and exposes all OpenAi request options, except messages and stream.
    • Add OpenAiChatOptions field (as defaultOptions) to OpenAiChatClient. Implement star-up/runtime options merging on chat request creation - Add OpenAiChatOptions options field to OpenAiChatProperties. Later is set as OpenAiChatClient#defaultOptions. Use the spring.ai.openai.chat.options.* prefix to set the options.
    • Add tests for properties and options merging.
  • Add OpenAiEmbeddingOptions

    • Add OpenAiEmbeddingOptions class implementing the EmbeddingOptions interface.
    • Add OpenAiEmbeddingClient#defaultOptions
    • Add request merging with default and propmt options.
    • Add OopenAiEmbeddingProperties#options field of type OpenAiEmbeddingOptions

Part of #228

@tzolov tzolov mentioned this pull request Jan 28, 2024
@tzolov tzolov added this to the 0.8.0 milestone Jan 28, 2024
@tzolov tzolov force-pushed the openai-chat-options-2 branch 2 times, most recently from 0947fcc to 048a153 Compare January 28, 2024 15:59
 - Add OpenAiChatOptions that implements ChatOptions and exposes all OpenAi request options, except messages and stream.
 - Add OpenAiChatOptions field (as defaultOptions) to OpenAiChatClient. Implement star-up/runtime options merging on chat request creation - Add OpenAiChatOptions options field to OpenAiChatProperties. Later is set as OpenAiChatClient#defaultOptions. Use the spring.ai.openai.chat.options.* prefix to set the options.
 - Add tests for properties and options merging.

 Part of spring-projects#228
 - Add OpenAiEmbeddingOptions class implementing the EmbeddingOptions interface.
 - Add OpenAiEmbeddingClient#defaultOptions
 - Add request merging with default and propmt options.
 - Add OopenAiEmbeddingProperties#options field of type OpenAiEmbeddingOptions
@tzolov tzolov force-pushed the openai-chat-options-2 branch from eb2f583 to 09cc4fd Compare January 28, 2024 18:12
@tzolov tzolov changed the title Add OpenAi Chat Options (2) Add OpenAi Chat and Embedding Options (2) Jan 29, 2024
@tzolov tzolov changed the title Add OpenAi Chat and Embedding Options (2) Add OpenAi Chat and Embedding Options Jan 29, 2024
* @return the merged object represented by the given class.
*/
public static <T> T merge(Object source, Object target, Class<T> clazz) {
public static <T> T merge(Object source, Object target, Class<T> clazz, List<String> acceptedFieldNames) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this list can be derived from clazz

e.g.

		if (this.defaultOptions != null) {
			request = ModelOptionsUtils.merge(request, this.defaultOptions, ChatCompletionRequest.class,
					REQUEST_JSON_FIELD_NAMES);
		}

and

	private static final List<String> REQUEST_JSON_FIELD_NAMES = ModelOptionsUtils
		.getJsonPropertyValues(ChatCompletionRequest.class);

@markpollack
Copy link
Member

merged in 5b4784f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants